/*LICENSE_BEGIN
 * ******************************************************************
 * Copyright 2006 by the Dainamite Robocup-Team at the
 * DAI-Labor, TU-Berlin (www.dai-labor.de)
 * 
 * Members of Dainamite are:
 * Holger Endert
 * Robert Wetzker
 * Thomas Karbe
 * Axel Heßler
 * Philippe Bütter
 * Felix Brossmann
 * 
 * Licensed under the GNU GPL (General Public License) Free Software 
 * License, Version 2. You may use this file only in compliance with 
 * the License. You may obtain a copy of the License at:
 * 
 * http://www.fsf.org/licensing/licenses/gpl.txt
 * ******************************************************************
LICENSE_END*/
package robocup.component.infotypes;

import robocup.component.geometry.Vektor;

/**
 * This class holds all information taht are available for seen players.
 * This is an extension of DynamicObjectInfo, which holds values for 
 * position and speed.
 */
public class PlayerInfo extends DynamicObjectInfo {

	/**
	 * Constant for friendly players.
	 */
	public static final int FRIEND = 0;

	/**
	 * Constant for enemy players.
	 */
	public static final int OPPONENT = 1;

	/**
	 * Constant, indicating that the team of the player is not known.
	 */
	public static final int UNKNOWN = 2;

	/**
	 * The seen body-direction of the player.
	 */
	private double bodyDir;

	/**
	 * The seen neck-angle of the player.
	 */
	private double headDir;

	/**
	 * The type (team) of the player.
	 */
	private int type;

	/**
	 * The seen pointing-direction for that player.
	 */
	private double pointDir;

	/**
	 * Flag, indicating that the player has tackled.
	 */
	private boolean tackle;

	/**
	 * Is the player a goalie?
	 */
	private boolean goalie;

	/**
	 * The name of his team. 
	 */
	private String teamName = "";

	/**
	 * Ths absolute position of that player.
	 */
	private Vektor absPlayerPosition = Vektor.getDummyInstance();

	/**
	 * Constructor, craetes a new PlayerInfo with all given data
	 * 
	 * @param cycle -
	 *            the cycle, when it was seen
	 * @param iType
	 * @param iNumber -
	 *            his trcot number
	 * @param iDistance -
	 *            the distance
	 * @param iDirection -
	 *            the direction
	 * @param iDistChange -
	 *            the distChange value
	 * @param iDirChange -
	 *            the dirChange value, both used for speed
	 * @param iBodyDir -
	 *            his body direction
	 * @param iHeadDir -
	 *            his head-direction
	 * @param iPointDir -
	 *            where he points at
	 * @param iTackle -
	 *            is he tackling
	 * @param iGoalie -
	 *            is he goalie
	 */
	public PlayerInfo(int cycle, int iType, int iNumber, double iDistance,
			double iDirection, double iDistChange, double iDirChange,
			double iBodyDir, double iHeadDir, double iPointDir,
			boolean iTackle, boolean iGoalie) {
		super(cycle, iNumber, iDistance, iDirection, iDistChange, iDirChange);
		this.bodyDir = iBodyDir;
		this.headDir = iHeadDir;
		this.pointDir = iPointDir;
		this.tackle = iTackle;
		this.goalie = iGoalie;
		this.type = iType;
	}

	/**
	 * @return Returns the players number.
	 */
	public int getNumber() {
		return getId();
	}

	/**
	 * @return Returns the bodyDir.
	 */
	public double getBodyDir() {
		return this.bodyDir;
	}

	/**
	 * @return true if teammate or self
 	 */
	public boolean isFriend() {
		return this.type == FRIEND;
	}

	/**
	 * @return true if opponent
	 */
	public boolean isOpponent() {
		return this.type == OPPONENT;
	}

	/**
	 * @return Returns true, if the players team is not known.
	 */
	public boolean isOfUnknownTeam() {
		return this.type == UNKNOWN;
	}

	/**
	 * @return Returns the headDir.
	 */
	public double getHeadDir() {
		return this.headDir;
	}

	/**
	 * @return Returns the type.
	 */
	public int type() {
		return this.type;
	}


	/**
	 * @return Returns the debug-string for this info-object.
	 */
	@Override
	public String toString() {
		return ("SeePlayer: " + getNumber() + " Dist:" + this.distance
				+ " Dir:" + this.direction + " dDist:" + super.getDistChange()
				+ " dDir:" + super.getDirChange() + " Type:"
				+ this.getInfoType() + " Goalie" + this.isGoalie());
	}
	

	/**
	 * @return Returns true, if the player was seen as goalie.
	 */
	public boolean isGoalie() {
		return this.goalie;
	}

	/**
	 * Setter for reusing the PlayerInfo sets the body direction
	 * @param bodyDir
	 */
	public void setBodyDir(double bodyDir) {
		this.bodyDir = bodyDir;
	}

	/**
	 * Setter for reusing the PlayerInfo sets if goalie or not
	 * @param goalie
	 */
	public void setGoalie(boolean goalie) {
		this.goalie = goalie;
	}

	/**
	 * Setter for reusing the PlayerInfo sets the head direction
	 * @param headDir
	 */
	public void setHeadDir(double headDir) {
		this.headDir = headDir;
	}

	/**
	 * Setter for reusing the PlayerInfo sets the point direction
	 * @param pointDir
	 */
	public void setPointDir(double pointDir) {
		this.pointDir = pointDir;
	}

	/**
	 * Setter for reusing the PlayerInfo sets if tackling
	 * @param tackle
	 */
	public void setTackle(boolean tackle) {
		this.tackle = tackle;
	}

	/**
	 * Setter for reusing the PlayerInfo sets the type
	 * @param type
	 */
	public void setType(int type) {
		this.type = type;
	}

	/**
	 * @return Returns the pointDir.
	 */
	public double getPointDir() {

		return this.pointDir;
	}

	/**
	 * @return Returns the tackle.
	 */
	public boolean isTackle() {

		return this.tackle;
	}

	/**
	 * @return Returns the calculatedPlayerPosition.
	 */
	public Vektor getAbsPlayerPosition() {

		return this.absPlayerPosition;
	}

	/**
	 * @param playerPosition
	 *            The calculatedPlayerPosition to set.
	 */
	public void setAbsPlayerPosition(Vektor playerPosition) {

		this.absPlayerPosition.copy(playerPosition);
	}

	/**
	 * @return Returns the name of the players team.
	 */
	public String getTeamName() {
		return teamName;
	}

	/**
	 * Sets the name of the players team.
	 * @param teamName
	 */
	public void setTeamName(String teamName) {
		this.teamName = teamName;
	}

}
